<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 万物皆对象 （） 

    // {姓名，性别，年纪，学历。。。。。。。技能，爱好，家庭成员}

    // new一个对象实例
    var obj1 = new Object();
    obj1.name = '赵四'
    obj1.age = 60
    obj1.sayhi = function () {
      console.log('hi');
    }
    obj1.sayhi()

    // 对象直接量
    var obj2 = {
      name: '刘能',
      age: 55,
      sayhello: function () {
        console.log('hello');
      },
      family: [
        {
          name: 'xiao1',
          say(name) {
            console.log(name + 'haha');
          }
        },
        {
          name: 'xiao2',
          say() {
            console.log('hehe');
          }
        }
      ]
    }
    obj2.sayhello()

    obj2.family[0].say('lisi')

    //es6 class
    class Person {
      constructor(name, age) {
        //this是指代new的东西（当前对象的引用）
        this.name = name;
        this.age = age;
      }
      eat() {
        console.log('我爱吃肉');
      }
      sleep() {

      }
    }

    var p1 = new Person('list', 88);
    //var p2 = new Person('list',88)
    console.log(p1, name);
    p1.eat();
  </script>
</body>

</html>